#include "odn_inp_Input.h"

//Standard library headers
#include <windows.h>

namespace ouden
{
	namespace input
	{
		
		void ODN_InputManager::CheckInput()
		{
		
			//Store old key states
		    for (int i=0;i<256;i++){
				oldkeys[i] = keys[i];
			}
		
		    //Get new key states
		    for (int i=0;i<256;i++){
				keys[i] = (GetAsyncKeyState(i) & 0x8000);
			}
		
			//Get the mouse location
			POINT pos;
			
			if (GetCursorPos(&pos) != 0) {	
			    
			    //Store the old position of the mouse
			    mouseoldpos = mousepos;
			    
			    //Save the new mouse position
				mousepos = Vector3D(pos.x, pos.y);
			    
			    //Find the vector of movement
			    mousevector = mousepos - mouseoldpos;
			    
			    //Get the distance moved
			    //mousedistance = mousevector.Length();
			    
			    //If the mouse moved
			    //if (mousedistance > 0){
					
					//Store the mouse direction
					//mouseangle = mousevector.Angle();
					
				//}
				
			}   
			else{
				
				//Could not load the mouse position so do nothing
				
			}
		
			//Update InputReceivers
			for (int i=0;i<inputreceivers.size();i++) {
				
				//Check the input for the InputReceiver
				inputreceivers[i]->CheckInput(keys);
				
			}
		
		}
		
	} //namespace input
} //namespace ouden
